var enquiry = {
    intiEnquiryForm:function(){
        var options = {
            dataType : 'json',
            beforeSerialize : function(form, options) {
                options.url = config.baseURL + 'enquiry/create.json';
            },
            beforeSubmit : function() {
                var title = $('#title').val();
                var content = $('#content').val();
                var companyName = $('#companyName').val();
                var contactPerson = $('#contactPerson').val();
                var tel = $('#tel').val();
                var email = $('#email').val();
                
                if(!title){
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'Title is null,please input a value!',
                        icon : 'warning',
                        width : 400
                    });
                    return false;
                }
                if(!content){
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'Contents is null,please input a value!',
                        icon : 'warning',
                        width : 400
                    });
                    return false;
                }
                if(!companyName){
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'Campany Name is null,please input a value!',
                        icon : 'warning',
                        width : 400
                    });
                    return false;
                }
                if(!contactPerson){
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'Contact person is null,please input a value!',
                        icon : 'warning',
                        width : 400
                    });
                    return false;
                }
                if(!tel){
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'Tel is null,please input a value!',
                        icon : 'warning',
                        width : 400
                    });
                    return false;
                }
                if(!email){
                   $.msgBox.alert({
                        title : 'Tips',
                        msg : 'E-mail is null,please input a value!',
                        icon : 'warning',
                        width : 400
                    });
                    return false;
                }
            	
                $('#enquiryForm').attr('action', config.baseURL + 'enquiry/create.json');
                return true;
            },
            success : function(data) {
                if(data.result=='success'){
                    $.msgBox.alert({
                        title:'Tips',
                        msg:'Operate Success!',
                        icon:'warning',
                        width:300,
                        yesFun:function(){
                            $('#enquiryForm').resetForm();
                        }
                    });
                }else{
                    $.msgBox.alert({
                        title:'Tips',
                        msg:'User name or password error!',
                        icon:'warning',
                        width:330
                    });
                }
            }
        };
        
        $('#enquiryForm').submit(function() {
            $(this).ajaxSubmit(options);
            return false;
        });
    }
};